from flask import Blueprint, Response, request
from ..model.Site import Site
from ..dal import SiteDAL

site = Blueprint('site', __name__)

@site.route('/getsite')
def getSite():
    sid = request.args.get("sid")
    res = SiteDAL.getSite(sid)
    if not res:
        res = 'null'
    return Response(res,content_type='application/json')

@site.route('/addsite')
def addSite():
    name = request.args.get("name")
    site = request.args.get("site")
    province = request.args.get("province")
    city = request.args.get("city")
    district = request.args.get("district")
    street = request.args.get("street")
    creater = request.args.get("creater")
    mod = Site(None,name,site,province,city,district,street,creater)
    res = SiteDAL.addSite(mod)
    return Response(res if res else "false")
 